<cfset mySelf = viewState.getValue("mySelf") />
<cfset resourceUrl = viewstate.getValue("resourceUrl")>
<cfset repoResource = viewstate.getValue("repoResource")>
<cfset currentUser = viewstate.getValue("currentUser")>

<cfif isStruct(currentUser) AND currentUser.isAuthenticated() AND currentUser.getRecord().getUserName() eq 'denny'>
	<cfset canEdit = true>
<cfelse>
	<cfset canEdit = false>
</cfif>

	<cffunction name="safeString" returntype="string" output="false">
		<cfargument name="stringToClean" required="true" type="string">
		<cfreturn rereplacenocase(stringToClean,'[^a-z|A-Z|0-9|_]','','all')>
	</cffunction>


<cfif listFirst(repoResource.mimetype,"/") eq "image">
	<cfif viewstate.getValue("imgIsWrapped") eq "">
		<img src="<cfoutput>#cgi.SCRIPT_NAME#?#cgi.query_string#</cfoutput>&imgIsWrapped=1">
		<cfoutput>
			<script>
			var details = '';
			<cfloop list="Name,Author,Message,Date,Kind,Path,Revision,Size,URL,MimeType" index="ff">
				details = details + '<div style="display:block;">#replace("<strong>#ff#</strong> #repoResource[ff][1]#","'","\'","all")#</div>';
			</cfloop>
			dojo.widget.byId('detailsPane').setContent(details);
			</script>
		</cfoutput>	
	<cfelse>
	  <cfcontent type="#repoResource.mimetype#" variable="#repoResource.content#" reset="true">
	</cfif>

<cfelseif listFirst(repoResource.mimetype,"/") eq "text">
	<cfoutput>
		<cfif canEdit>
			<div dojoType="PopupMenu2" widgetId="submenu#repoResource.kind#" contextMenuForWindow="false" targetNodeIds="resource#safestring(resourceUrl)#">
				<div dojoType="MenuItem2" caption="Edit Content" onClick="dojo.widget.byId('resource#safestring(resourceUrl)#').setUrl('#myself#repo.resource.edit&resourceUrl=#repoResource.path#:#repoResource.revision#');"></div>
				<div dojoType="MenuItem2" caption="View Content" disabled="true" <!---onclick="setMainPane('#myself#dpage.edit&pageID=#page.pageID#');" --->></div>
		<!---
				<div dojoType="MenuSeparator2"></div>
				<div dojoType="MenuItem2" caption="Enabled Submenu" submenuId="submenu2"></div>
				<div dojoType="MenuItem2" caption="Disabled Submenu" submenuId="submenu2" disabled="true"></div>
		 --->
			</div>
		</cfif>
		<script>
			var details = '';
			<cfloop list="Name,Author,Message,Date,Kind,Path,Revision,Size,URL,MimeType" index="ff">
				details = details + '<div style="display:block;">#replace("<strong>#ff#</strong> #repoResource[ff][1]#","'","\'","all")#</div>';
			</cfloop>
			dojo.widget.byId('detailsPane').setContent(details);
		</script>
		<div style="display:inline;" id="resource#safestring(resourceUrl)#" dojoType="ContentPane" executeScripts="true">
		<cfif findNoCase(".cfm",repoResource.name) OR findNoCase(".cfc",repoResource.name)>
			<cfif viewstate.getValue("cfIsWrapped") eq "">
				<iframe src="<cfoutput>#cgi.SCRIPT_NAME#?#cgi.query_string#</cfoutput>&cfIsWrapped=1" width="100%" height="100%" frameborder="0"/>
			<cfelse>
				<html><head><link rel="stylesheet" href="/srvinc/js/star-light/star-light.css" type="text/css"/></head>
				<pre class="cf">#htmlEditFormat(toString(repoResource.content))#</pre></html>
			</cfif>
		<cfelseif repoResource.mimeType eq "text/html">
			#toString(repoResource.content)#
		<cfelse>
			#htmlEditFormat(toString(repoResource.content))#
		</cfif>
		<cfif trim(toString(repoResource.content)) eq "">No content</cfif>
		</div>
	</cfoutput>
<cfelse>
	<cfloop list="Name,Author,Message,Date,Kind,Path,Revision,Size,URL,MimeType" index="ff">
		<cfoutput>
		<div style="display:block;">#replace("<strong>#ff#</strong> #repoResource[ff][1]#","'","\'","all")#</div>
		</cfoutput>
	</cfloop>
</cfif>

		
